//
//  NSString+nickname.h
//  AddressBook
//
//  Created by mac on 2017/8/26.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "NSString+nickname.h"


@implementation NSString (nickname)

+(NSString *)stringInputKeyKnowStatus:(NSString *)key{
    
    NSString * status;
    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
    status = [userDefaults objectForKey:key];
    return status;
}

+(void)changeStatusWithKey:(NSString *)key newStatus:(NSDictionary *)status{
    
    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:status forKey:key];
    [userDefaults synchronize];
}


+(void)updateCurUserDataWithNewValue:(NSString *)newValue key:(NSString *)key{
//    NSString *info = @"[userinfo]";
//    NSString *value = [NSString stringWithFormat:@"%@%@",info,newValue];
    NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
    NSDictionary * user = [userDefaults objectForKey:KUSERINFORMATION];
    NSMutableDictionary * mutable = [NSMutableDictionary dictionaryWithDictionary:user[@"userinfo"]];
    mutable[key] = newValue;
    [userDefaults setObject:[NSDictionary dictionaryWithDictionary:mutable] forKey:KUSERINFO];
    [userDefaults synchronize];
}

@end
